import xID from "./xID.js";
import table from "./dynamicTable.js";
import pivot from "./dynamicPivot.js";
import cube from "./dynamicCube.js";
import SysApi from "../SysApi/SysApi.js";

let modules ={
	table,
	pivot,
	cube,
	SysApi
};

let currentModule;

$(".nav-link").click(e =>{
	let module = e.target.getAttribute("href");
	run(module);	 
}) ;

const tmplDiv = '<div id="{mId}"></div>';

function run(module){
	if(currentModule)
	    currentModule.close();

	if( modules[module]){
        let mId = xID.getID();
        $("#app").html(tmplDiv.replace("{mId}",mId));
        currentModule = modules[module];
        currentModule.init(mId);
    }

}
